package stage1.module4.task1;

public class Employee  {

    private String name;
    private int age;

    public Employee() {
    }

    public Employee(String name, int age) throws AgeException, NameException {
        setName(name);
        setAge(age);
    }

    public String getName() {
        return name;
    }

    public void setName(String name)  throws NameException{
        if ((null == name) || "".equals(name)) {
            throw new NameException("空异常");
        }
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) throws AgeException{
        if (18 > age || 150 < age) {
            throw new AgeException("年龄异常");
        }
        this.age = age;
    }


}
